import {
  IS_CLOSE_OTHER_PET,
  IS_CLOSE_CHILDREN,
  IS_CLOSE_CHILDREN_LIST,
  IS_CLOSE_OTHER_PET_LIST,
} from '@/const/type';

export const tableOption = (isView = false, isDisplay) => {
  const option = {
    ...window.$crudMixins.tableOptions,
    addBtn: false,
    editBtn: false,
    delBtn: false,
    menuWidth: 260,
    labelWidth: 140,
    emptyBtn: false,
    submitBtn: false,
    detail: isView,
    group: [
      // {
      //   label: '首页推荐',
      //   prop: 'group2',
      //   column: [
      //     {
      //       label: '是否首页推荐',
      //       prop: 'pushHomePage',
      //       type: 'radio',
      //       dicData: IS_SHOW_HOME_LIST,
      //       rules: [
      //         {
      //           required: true,
      //           message: '请选择是否首页推荐',
      //         },
      //       ],
      //     },
      //   ],
      // },
      {
        label: '宣传图片/视频',
        prop: 'group1',
        labelWidth: 110,
        column: [
          {
            label: '',
            prop: 'petFile',
            type: 'upload',
            fileSize: 50 * 1024, // 写在这里直接拦截没有提示
            // listType: 'picture-card',
            listType: 'picture-card',
            // fileType: 'video', //img/video/audio
            propsHttp: {
              name: 'hash',
              url: 'key',
            },
            props: {
              label: 'name',
              value: 'url',
            },
            // action: 'http://upload-z2.qiniup.com',
            oss: 'qiniu',
            tip: '最多可上传30个图片/视频',
            row: true,
            span: 24,
            accept: '.mp4, .mpeg, .WMV, .mov, .jpg, .png, .jpeg, .webp, .heic',
            limit: 30,
            drag: true,
            multiple: true,
            rules: [
              {
                required: true,
                message: '请上传宣传图片/视频',
                trigger: 'blur',
              },
            ],
          },
        ],
      },
      {
        label: '它的故事',
        prop: 'group3',
        column: [
          {
            type: 'textarea',
            label: '',
            prop: 'introduction',
            span: 24,
            rules: [
              {
                required: true,
                message: '请输入它的故事',
              },
            ],
            showWordLimit: true,
            maxlength: 1000,
          },
          {
            label: '置顶状态',
            prop: 'topFlag',
            type: 'select',
            display: isDisplay,
            dicData: [
              {
                label: '未置顶',
                value: '0',
              },
              {
                label: '已置顶',
                value: '1',
              },
            ],
          },
          {
            label: '置顶时间',
            prop: 'topTime',
            display: isDisplay,
            formsolt: true,
          },
          {
            label: '上架更新时间',
            prop: 'updateTime',
            display: isDisplay,
          },
        ],
      },
      {
        label: '它的个性标签',
        prop: 'group4',
        column: [
          {
            label: '性格/喜好标签',
            prop: 'personality',
            type: 'select',
            multiple: true,
            rules: [
              {
                required: !isView,
                message: '请选择性格标签',
              },
            ],
            // dicUrl: `/core/attribute/list/bind/CAT/personality`,
            props: {
              label: 'attributeName',
              value: 'attributeCode',
            },
          },
          {
            label: '基地状态/人气',
            prop: 'popularity',
            type: 'select',
            multiple: true,
            dicUrl: `/core/attribute/list/bind/CAT/popularity`,
            props: {
              label: 'attributeName',
              value: 'attributeCode',
            },
            rules: [
              {
                required: !isView,
                message: '请选择基地状态/人气',
              },
            ],
          },
          {
            label: '是否亲近儿童',
            prop: 'likeChildren',
            type: 'radio',
            dicData: IS_CLOSE_CHILDREN_LIST,
            value: IS_CLOSE_CHILDREN.YES,
            rules: [
              {
                required: !isView,
                message: '请选择是否亲近儿童',
              },
            ],
          },
          {
            label: '是否亲近其他宠物',
            prop: 'likeOtherPets',
            type: 'radio',
            dicData: IS_CLOSE_OTHER_PET_LIST,
            value: IS_CLOSE_OTHER_PET.YES,
            rules: [
              {
                required: !isView,
                message: '请选择是否亲近其他宠物',
              },
            ],
          },
          {
            label: '其他特征',
            prop: 'otherCharacteristics',
            type: 'select',
            row: true,
            multiple: true,
            rules: [
              {
                required: false,
                message: '请选择其他特征',
              },
            ],
            dicUrl: '/admin/dict/type/other_preferences',
          },

          {
            label: '分配所属区域',
            prop: 'areaId',
            type: 'select',
            row: true,
            formsolt: true,
            rules: [
              {
                required: true,
                message: '请选择所属区域',
              },
            ],
            // dicUrl: '/core/cloud/adopt/area/list',
            // props: {
            //   label: 'name',
            //   value: 'id',
            // },
          },
          {
            label: '猫咪带来的寓意',
            prop: 'meaning',
            span: 24,
            maxlength: 18,
            placeholder: '请输入云认养横幅展示该猫咪带来的寓意',
            showWordLimit: true,
            rules: [
              {
                required: true,
                message: '请输入猫咪带来的寓意',
              },
            ],
          },
        ],
      },
      {
        label: '它的最近动态',
        prop: 'group5',
        column: [
          {
            label: '最近动态',
            prop: 'content',
            slot: true,
            span: 24,
            maxlength: 10,
            rules: [
              {
                required: !isView,
                message: '请输入最近动态',
              },
            ],
          },
        ],
      },
    ],
  };
  if (isView) {
    option.group.push({
      label: '推荐它喜欢的商品',
      prop: 'group6',
      column: [
        {
          label: '',
          labelWidth: 0,
          prop: 'goods',
          slot: true,
          span: 24,
        },
      ],
    });
  }
  return option;
};
